/// <summary>
/// File:		LockObj.h
/// Author:		Dennis Norton
/// Date:		03/28/12
/// Purpose:	This class creates a lockable objects to make varibles multi-threading safe.
/// </summary>

#ifndef LOCKOBJ_H_
#define LOCKOBJ_H_

#include "../../Norton Game/Program Includes.h"

class LockObj
{
	bool _isLocked;
	CRITICAL_SECTION _CS;
public:
	LockObj();
	~LockObj();

	/// <summary>
	/// Function:	Lock
	/// Author:	Dennis Norton
	/// Date:		03/28/12
	/// Purpose:	This function call locks the thread in a critical section. This is a blocking call.
	/// </summary>
	void Lock();

	/// <summary>
	/// Function:	UnLock
	/// Author:	Dennis Norton
	/// Date:		03/28/12
	/// Purpose:	This call unlocks the thread, leaving the critical section.
	/// </summary>
	void UnLock();

	/// <summary>
	/// Function:	TryLocking
	/// Author:	Dennis Norton
	/// Date:		03/28/12
	/// Purpose:	This call tries to lock the calling thread. Returns true on a successful lock. Non-blocking call.
	/// </summary>
	bool TryLocking();

	/// <summary>
	/// Function:	IsLocked
	/// Author:	Dennis Norton
	/// Date:		03/28/12
	/// Purpose:	This call returns whether or not the thread is locked or not.
	/// </summary>
	bool IsLocked();
};
#endif